import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import 'swiper/css/swiper.css'
// 引入jQuery、bootstrap
import $ from 'jquery'
import 'bootstrap'
// 引入bootstrap样式
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap/dist/js/bootstrap'
// 全局注册$
Vue.prototype.$ = $
Vue.use(ElementUI)
Vue.config.productionTip = false

// 注册全局指令
Vue.directive('errImg', {
  inserted (el, binding) {
    el.addEventListener('error', function () {
      el.src = binding.value
    })
    el.src = el.src || binding.value
  },
  componentUpdated (el, binding) {
    el.addEventListener('error', function () {
      // console.log('图片报错了！', binding)
      el.src = binding.value
    })
    el.src = el.src || binding.value
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
